package com.sky.controller.admin;


import com.sky.constant.RedisKeyConstant;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags="店铺状态接口")
public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;

    @PutMapping("/{status}")
    public Result changeShopStatus(@PathVariable("status") Integer status){
        redisTemplate.opsForValue().set(RedisKeyConstant.SHOP_STATUS_KEY,status);
        return Result.success();
    }

    @GetMapping("/status")
    public Result getShopStatus(){
        Integer o = (Integer)redisTemplate.opsForValue().get(RedisKeyConstant.SHOP_STATUS_KEY);
        return Result.success(o);
    }
}
